define(["jquery", "easy-admin"], function ($, ea) {
	
	$(".js-clip").click(function () {
		
        var text = $(this).html();
        if (text == "") {
            return false;
        } 
        
        if (window.clipboardData) {
        	window.clipboardData.clearData();
        	window.clipboardData.setData('text', text);
        }
        // for modern browser
        else if (document.execCommand) {
        	var element = document.createElement('SPAN');
        	element.textContent = text;
        	document.body.appendChild(element);
        	if (document.selection) {
        		var range = document.body.createTextRange();
        		range.moveToElementText(element);
        		range.select();
        	} else if (window.getSelection) {
        		var range = document.createRange();
        		range.selectNode(element);
        		window.getSelection().removeAllRanges();
        		window.getSelection().addRange(range);
        	}
        	document.execCommand('copy');
        	element.remove ? element.remove() : element.removeNode(true);
        }

        layer.msg("复制成功",{icon: 1});
        
    })
	
	
	$("span").mouseover(function () {

		var toggle = $(this).attr('data-toggle'); 
		
		if(toggle!='popover'){
			return;
		}
		
		var row = $(this).attr('data-content'); //获取显示内容
	      
        layer.tips(row,$(this), {
        	  tips: [2, '#fff']
        })
    })

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'dpjz.system/index',
        add_url: 'dpjz.system/add',
        edit_url: 'dpjz.system/edit',
        delete_url: 'dpjz.system/delete',
        export_url: 'dpjz.system/export',
        modify_url: 'dpjz.system/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},                    {field: 'id', title: 'id'},                    {field: 'logo', title: '系统logo', templet: ea.table.image},                    {field: 'name', title: '系统名称'},                    {field: 'phone', title: '客服电话'},                    {field: 'share_pic', title: '分享图片', templet: ea.table.image},                    {field: 'share_title', title: '分享标题'},                    {field: 'create_time', title: '创建时间'},                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});